#include "Application.h"
#include "Control.h"
#include "Form.h"
#include "Button.h"

namespace MiniWindow
{
	DWORD Application::_thread = 0;
	HINSTANCE Application::_instance = null;

	void Application::Init(HINSTANCE instance)
	{
		Application::_instance = instance;
		Application::_thread = GetCurrentThreadId();
	}
	int Application::Run()
	{
		return Application::MessageLoop();
	}
	void Application::Exit()
	{
		PostThreadMessage(Application::_thread, WM_QUIT, 0, 0);
	}

	HINSTANCE Application::GetInstance()
	{
		return Application::_instance;
	}
	int Application::MessageLoop()
	{
		MSG msg;
		while (GetMessage(&msg, null, 0, 0))
		{
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}
		return msg.wParam;
	}
}